//
//  HDRegisterCell.swift
//  HuaDaoPeifu
//
//  Created by Erickson on 16/4/7.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

class HDRegisterCell: UITableViewCell {

    @IBOutlet weak var titleWidth: NSLayoutConstraint!
    @IBOutlet weak var getCodeButton: UIButton!
    @IBOutlet weak var textField: UITextField!
    @IBOutlet weak var titleName: UILabel!
    
    var timer = Timer()
    var timeCount = 10
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    
    func startTimer() {
        getCodeButton.isEnabled = false
        timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(HDRegisterCell.beginCountDown), userInfo: nil, repeats: true)
    }
    
    func beginCountDown() {
        // print(timeCount)
        timeCount -= 1
        
        getCodeButton.setTitle("(\(timeCount))", for: .disabled)
        if timeCount == 0 {
            getCodeButton.isEnabled = true
            timer.invalidate()
            timeCount = 60
        }
   
        
    }
    
}
